<template>
  <el-container style="height: 100vh;overflow:hidden;">
    <el-header>
      <div class="logo"/>
      <div class="title">质检中心全过程管理工具</div>
      <div style="float: right;display: flex;  align-items: center;">
        <span style="color: white;margin-right: 5px">{{ sttUser.nickname }}</span>
        <el-button type="text" style="float:right" @click="exit">退出</el-button>
      </div>

    </el-header>
    <el-container style="overflow:hidden;">
      <el-aside
          style="background: #001529;width: 200px;overflow-y: auto;overflow-x: hidden;height: 100%">
        <el-menu router background-color="#001529" text-color="#FFFFFFdd"
                 default-active="/home/welcome"
                 :collapse="false">
          <el-menu-item index="/home/welcome">
            <template #title>欢迎</template>
          </el-menu-item>
          <el-menu-item index="/home/real">
            <template #title>实时监控</template>
          </el-menu-item>
          <el-menu-item index="/home/capture">
            <template #title>我的抓拍</template>
          </el-menu-item>
          <el-menu-item v-if="sttUser.role ===1" index="/home/video">
            <template #title>我的回放</template>
          </el-menu-item>
          <el-menu-item index="/home/device">
            <template #title>设备管理</template>
          </el-menu-item>
          <el-menu-item v-if="sttUser.role ===1" index="/home/log">
            <template #title>系统日志</template>
          </el-menu-item>
          <el-menu-item v-if="sttUser.role ===1" index="/home/user">
            <template #title>用户管理</template>
          </el-menu-item>
        </el-menu>
      </el-aside>
      <el-container style="overflow: hidden">
        <el-main>
          <div style="background: #fff;height: 100%;">
            <router-view/>
          </div>
        </el-main>
        <el-footer height="64px" style="display: flex;background: #001529;color: #fff;align-items: center;
    justify-content: space-evenly;">
          版权信息@2024
        </el-footer>
      </el-container>
    </el-container>
  </el-container>
</template>
<script setup name="HomeView" lang="ts">

import {onMounted, ref} from 'vue';
import User from "@/model/User";
import {useRouter} from "vue-router";
import UserApi from "@/axios/UserApi";


const sttUser = ref(new User());

onMounted(async () => {
  UserApi.getLoginUser().then(resp => {
    sttUser.value.username = resp.data?.username
    sttUser.value.nickname = resp.data?.nickname
    sttUser.value.role = resp.data?.role
  })
})


const router = useRouter()
const exit = () => {
  localStorage.clear()
  router.push("/")
}

</script>

<style lang="less">
#components-layout-demo-top-side-2 .logo {
  float: left;
  width: 120px;
  height: 31px;
  margin: 16px 24px 16px 0;
  background: rgba(255, 255, 255, 0.3);
}

.background {
  position: fixed;
  min-width: 100%;
  min-height: 100%;
  background: url("../assets/login_back.jpg");
  z-index: -1;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-size: cover;
}

.ant-row-rtl #components-layout-demo-top-side-2 .logo {
  float: right;
  margin: 16px 0 16px 24px;
}

.site-layout-background {
  background: #fff;
}


.box-card {
  margin-bottom: 10px;
}

.el-header {
  display: flex;
  width: 100%;
  height: 80px !important;
  background: #001529;
  z-index: 10;
  align-items: center;
  justify-content: space-between;
}

.logo {
  width: 80px;
  height: 40px;
  margin: 20px 24px 20px 0;
  float: left;
}

.title {
  text-align: center;
  color: #FFF;
  font-size: 30px;
  z-index: 9;
}

.site-layout .site-layout-background {
  background: #fff;
}

.ant-layout-header {
  height: 80px;
}

.ant-layout-footer {
  text-align: center;
  color: #fff;
  background: #000614;
}


[data-theme='dark'] .site-layout .site-layout-background {
  background: #14141400;
}
</style>